export default {
  initWebsocket(state){
    const wsUrl='ws://10.0.0.106:8080/websocket/111/1';
    const ws=new WebSocket(wsUrl);
    ws.onopen=function () {
      ws.send(JSON.stringify({
        dealName:'getServerTime'
      }));
    };
    ws.onmessage=function (e) {
      const data=JSON.parse(e.data);
      state[data.dealName]=data.message;
      console.log('state中数据已更新');
      window.localStorage.setItem('imMsg',JSON.stringify(state.imMessages));
    };
    ws.close=function () {
      console.log('连接已断开');
    }
    state.websocket=ws;
  },
}
